package com.qingcloud.base.api.remote.executor;

import com.qingcloud.base.api.remote.executor.factory.ExecutorApiFallbackFactory;
import com.qingcloud.base.constant.AppNameConstant;
import com.qingcloud.base.exception.WamingException;
import com.qingcloud.base.pojo.ApiResult;
import com.qingcloud.base.remote.executor.ExecutorParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


/**
 * 服务式运行中心提供的接口
 */
@FeignClient(contextId = "executorApi", path = "executor", value = AppNameConstant.APP_EXECUTOR, fallbackFactory = ExecutorApiFallbackFactory.class)
public interface ExecutorApi {

    /////////////////////////////////////////////new
    //@ApiOperation(value = "启动作业实例", notes = "启动作业实例")
    @PostMapping("/instance/start")
    ApiResult startInstance(@RequestBody ExecutorParam.InstanceParam instanceParam) throws Exception ;

    //@ApiOperation(value = "停止作业实例", notes = "停止作业实例")
    @PostMapping("/instance/stop")
    public ApiResult stopInstance(@RequestBody ExecutorParam.InstanceParam instanceParam) throws WamingException ;


    //@ApiOperation(value = "清理作业实例", notes = "清理作业实例")
    @PostMapping("/instance/cleanup")
    public ApiResult destroyInstance(@RequestBody ExecutorParam.InstanceParam instanceParam) throws WamingException;

    /////////////////////PowerJob//////////////////////////
   // @ApiOperation(value = "保存或更新到PowerJob", notes = "保存到PowerJob")
    @PostMapping("/instance/saveTask")
    public ApiResult saveTask(@RequestBody ExecutorParam.InstanceParam instance) throws WamingException;

   // @ApiOperation(value = "删除PowerJob", notes = "删除PowerJob")
    @PostMapping("/instance/deleteTask")
    public ApiResult deleteTask(@RequestBody ExecutorParam.InstanceParam instance) throws WamingException;


   // @ApiOperation(value = "触发PowerJob Task", notes = "触发PowerJob Task")
    @PostMapping("/instance/triggerTask")
    public ApiResult triggerTask(@RequestBody ExecutorParam.InstanceParam instance) throws WamingException;


   // @ApiOperation(value = "触发PowerJob Task", notes = "触发PowerJob Task")
    @PostMapping("/instance/getTaskCron")
    public ApiResult getCron(@RequestBody ExecutorParam.InstanceParam instance) throws WamingException;

    ////////////////////////////end////////////

    //@ApiOperation(value = "启动作业", notes = "启动作业")
    @PostMapping("/job/start")
    public ApiResult startJob(@RequestBody ExecutorParam.JobParam jobParam) throws WamingException;


    //@ApiOperation(value = "停止作业", notes = "停止作业")
    @PostMapping("/job/stop")
    public ApiResult stopJob(@RequestBody ExecutorParam.JobParam jobParam) throws WamingException ;

    //@ApiOperation(value = "清理作业", notes = "清理作业")
    @PostMapping("/job/cleanup")
    public ApiResult destroyJob(@RequestBody ExecutorParam.JobParam jobParam) throws WamingException  ;


    //@ApiOperation(value = "导入作业", notes = "导入作业")
    @PostMapping("/job/import")
    public ApiResult importJob(MultipartFile file) throws Exception ;


    //@ApiOperation(value = "提取组件基本配置信息", notes = "提取组件基本配置信息")
    @PostMapping("/component/baseConfig")
    public ApiResult baseConfig(@RequestBody ExecutorParam.ComponentConfigParam compParam) throws WamingException;


    //@ApiOperation(value = "提取组件动态输出配置信息", notes = "提取组件动态输出配置信息")
    @PostMapping("/component/syncConfig")
    public ApiResult syncConfig(@RequestBody ExecutorParam.ComponentConfigParam compParam) throws WamingException ;

}
